package util;

/**
 * @author wuyunbin
 */
public class String2JsonUtil {
    public static String string2Json(String images){
        String[] imagesArray = images.split(",");
        int length = imagesArray.length;
        StringBuilder imagesJsonStr = new StringBuilder("{");
        for (int i = 0; i < length; i++) {
            imagesJsonStr.append("\"img").append(i + 1).append("\":\"").append(imagesArray[i]).append("\",");
        }
        imagesJsonStr = new StringBuilder(imagesJsonStr.substring(0, imagesJsonStr.length() - 1));
        imagesJsonStr.append("}");
        return imagesJsonStr.toString();
    }
}
